﻿/// <reference path="BaseTextNode.js" />
/// <reference path="TreeNodeType.js" />

var $CheckBoxNode = TA.Turbo.Controls.CheckBoxNode = function CheckBoxNode()
{
	this.BaseTextNode();
}
$CheckBoxNode.Inherit($BaseTextNode);

var ____a;
if (____a)
{
	$CheckBoxNode.prototype = new $BaseTextNode();
	$CheckBoxNode.prototype.BaseTextNode = new $BaseTextNode();
}

$CheckBoxNode.prototype.Checked = null;
$CheckBoxNode.prototype._label = null;
$CheckBoxNode.prototype._checkbox = null;


$CheckBoxNode.prototype.get_Type = function get_Type()
{
	return TreeNodeType.CheckBox;
}

$CheckBoxNode.prototype.SerializeContents = function SerializeContents(jw)
{
	this.BaseTextNode.SerializeContents.call(this, jw);

	if (this.Checked != null)
	{
		jw.Property("K", this.Checked);
	}
}
$CheckBoxNode.prototype.DeserializeContent = function DeserializeContent(propShortName, value)
{
	switch (propShortName)
	{
		case "K": this.Checked = value; break;
		default: this.BaseTextNode.DeserializeContent.call(this, propShortName, value); break;
	}
}
$CheckBoxNode.prototype._CreateContent = function _CreateContent()
{
	this._label = document.createElement("LABEL");
	if (this.ToolTip != null)
		this._label.setAttribute("title", this.ToolTip);
	this.get_DivContent().appendChild(this._label);

	this._checkbox = document.createElement("INPUT");
	this._checkbox.type = "checkbox";
	if (this.Checked)
		this._checkbox.checked = true;
	this._label.appendChild(this._checkbox);

	var textNode = document.createTextNode(" " + this.Text);
	this._label.appendChild(textNode);

	this._checkbox.AddEvent("change", this._checkbox_Change, this);
}
$CheckBoxNode.prototype._ParseContent = function _ParseContent()
{
	this._label = this.get_DivContent().FindFirstChild("LABEL");
	this._checkbox = this._label.FindFirstChild("INPUT");

	this._checkbox.AddEvent("change", this._checkbox_Change, this);
}
$CheckBoxNode.prototype._checkbox_Change = function _anchor_Click(e)
{
	this.Checked = this._checkbox.checked;
}
